package org.example.rabbitmqdemo.controller;

import org.example.rabbitmqdemo.constant.Constants;
import org.example.rabbitmqdemo.service.DeleteIllegalService;
import org.example.rabbitmqdemo.service.DeleteOutlierService;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("producer")
public class ProducerController {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @RequestMapping("/work")
    public String work(String msg) {
        rabbitTemplate.convertAndSend("", Constants.WORK_QUEUE, msg);
        return "发送成功";
    }
    @Autowired
    private DeleteIllegalService deleteIllegalService;
    @RequestMapping("/direct/deleteIllegal")
    public String direct1(String msg) {
        msg = deleteIllegalService.solution1(msg);
        rabbitTemplate.convertAndSend(Constants.DIRECT_EXCHANGE,"deleteIllegal",msg);
        return "传输成功，去除除字母数字外的非法字符";
    }
    @Autowired
    private DeleteOutlierService deleteOutlierService;
    @RequestMapping("/direct/deleteOutlier")
    public String direct2(String msg) {
        msg = deleteOutlierService.solution2(msg);
        rabbitTemplate.convertAndSend(Constants.DIRECT_EXCHANGE,"deleteOutlier",msg);
        return "传输成功，去除小于0的异常值";
    }

}
